package com.business.web.spring;


import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.business.domain.T_company;
import com.business.domain.T_goods;
import com.business.domain.T_img;
import com.business.service.T_companyService;
//import com.business.mapper.T_goodsMapper;
import com.business.service.T_goodsService;
import com.business.service.T_imgService;
//import com.workflow.WorkFlowUtils;
import com.common.db.JsonVO;
import com.common.db.Pg;
import com.common.utils.BeanUtils;
import com.system.service.LxConstans;

@Controller
@RequestMapping("/t_goods")

public class T_goodsController
{
	private static Logger log = Logger.getLogger(T_goodsController.class.getName());

	@Resource
	private T_goodsService t_goodsService;
	@Resource
	private T_imgService t_imgService;
	@Resource
	private T_companyService t_companyService;
	//@Autowired
	//private WorkFlowUtils workFlowUtils;

	//@Resource
	//private T_goodsMapper mapper;
	//private int id;
	private int[] batchSelected;
	private Pg pg;

	/**
	 * 1、1获取 T_goods信息列表，并且在列表页面展示
	 * @param request
	 * @return Pg，json格式
	 */
	@RequestMapping("/getAllT_goods")
	@ResponseBody
	public Pg getAllT_goods(HttpServletRequest request){
		int pageSize = 10;
		int startIndex = 0;
		T_goods t_goods = new T_goods();
		try{
			if(request.getParameter("pageSize")!=null){
				pageSize = BeanUtils.stringToInt("pageSizeFlag", request.getParameter("pageSize"));
			}
			if(request.getParameter("startIndex")!=null){
				startIndex = BeanUtils.stringToInt("startIndexFlag", request.getParameter("startIndex"));
			}
			if(request.getParameter("process_code")!=null){ //取得动作流 流程英文名称，后台查询数据关联使用
				t_goods.setProcess_code(request.getParameter("process_code"));
			}
			if(request.getParameter("goods_name")!=null&&!"".equals(request.getParameter("goods_name"))){
				//中文乱码
				String goodsNm = "";
				goodsNm = new String(request.getParameter("goods_name"));
				//t_goods.setGoods_name(request.getParameter("goods_name"));
				t_goods.setGoods_name(goodsNm);
			}
			if(request.getParameter("goods_info")!=null&&!"".equals(request.getParameter("goods_info"))){
				t_goods.setGoods_info(request.getParameter("goods_info"));
			}
			if(request.getParameter("goods_memo")!=null&&!"".equals(request.getParameter("goods_memo"))){
				t_goods.setGoods_memo(request.getParameter("goods_memo"));
			}
			if(request.getParameter("img_path")!=null&&!"".equals(request.getParameter("img_path"))){
				t_goods.setImg_path(request.getParameter("img_path"));
			}
			if(request.getParameter("isnew")!=null&&!"".equals(request.getParameter("isnew"))){
				t_goods.setIsnew(request.getParameter("isnew"));
			}
			if(request.getParameter("ishot")!=null&&!"".equals(request.getParameter("ishot"))){
				t_goods.setIshot(request.getParameter("ishot"));
			}
			if(request.getParameter("ext1")!=null&&!"".equals(request.getParameter("ext1"))){
				t_goods.setExt1(request.getParameter("ext1"));
			}
			if(request.getParameter("ext2")!=null&&!"".equals(request.getParameter("ext2"))){
				t_goods.setExt2(request.getParameter("ext2"));
			}
			if(request.getParameter("ext3")!=null&&!"".equals(request.getParameter("ext3"))){
				t_goods.setExt3(request.getParameter("ext3"));
			}
			if(request.getParameter("customer_id")!=null&&!"".equals(request.getParameter("customer_id"))){
				t_goods.setCustomer_id(request.getParameter("customer_id"));
			}
			if(request.getParameter("customer_name")!=null&&!"".equals(request.getParameter("customer_name"))){
				t_goods.setCustomer_name(request.getParameter("customer_name"));
			}
			if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
				t_goods.setStatus(request.getParameter("status"));
			}
			if(request.getParameter("goods_id")!=null&&!"".equals(request.getParameter("goods_id"))){
				t_goods.setGoods_id(new Integer(request.getParameter("goods_id")));
			}
			if(request.getParameter("product_id")!=null&&!"".equals(request.getParameter("product_id"))){
				t_goods.setProduct_id(new Integer(request.getParameter("product_id")));
			}
			if(request.getParameter("startdate")!=null&&!"".equals(request.getParameter("startdate"))){
				t_goods.setStartdate(request.getParameter("startdate"));
			}
			if(request.getParameter("enddate")!=null&&!"".equals(request.getParameter("enddate"))){
				t_goods.setEnddate(request.getParameter("enddate"));
			}
			if(request.getParameter("orderByClause")!=null&&!"".equals(request.getParameter("orderByClause"))){
				t_goods.setOrderByClause(request.getParameter("orderByClause"));
			}
			if(request.getParameter("product_name1")!=null&&!"".equals(request.getParameter("product_name1"))){
				t_goods.setProduct_name1("&nbsp;&nbsp;"+request.getParameter("product_name1")+">>");
			}
			if(request.getParameter("product_name2")!=null&&!"".equals(request.getParameter("product_name2"))){
				//t_goods.setProduct_name2("&nbsp;&nbsp;"+ java.net.URLDecoder.decode(request.getParameter("product_name2"),"UTF-8")+">>");
				t_goods.setProduct_name2("&nbsp;&nbsp;"+ request.getParameter("product_name2")+">>");
			}
			if(request.getParameter("product_name3")!=null&&!"".equals(request.getParameter("product_name3"))){
				t_goods.setProduct_name3("&nbsp;&nbsp;"+request.getParameter("product_name3")+">>");
			}

			t_goods.setStartNo( startIndex );
			t_goods.setPageSize( pageSize );
			t_goods.setEndNo( pageSize );
			//List<T_goods> findAll = t_goodsService.findAllBySearch(t_goods);
			//int totalCount = t_goodsService.findCountAllBySearch(t_goods);
			List<T_goods> findAll = t_goodsService.findAll(t_goods);
			int totalCount = t_goodsService.findCountAll(t_goods);
			pg = new Pg(findAll, totalCount, pageSize, startIndex);
			request.setAttribute("t_goodsList", findAll);
			request.setAttribute("pg", pg);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("------query t_goodsList error:"+e);
		}

		return pg;
	}

	/**
	 * 1、2获取 T_goods信息列表，并且在列表页面展示
	 * @param request
	 * @return Pg，json格式
	 */
	@RequestMapping("/findAllT_goodsProduct")
	@ResponseBody
	public Pg findAllT_goodsProduct(HttpServletRequest request){
		int pageSize = 1000;
		int startIndex = 0;
		T_goods t_goods = new T_goods();
		try{
			if(request.getParameter("pageSize")!=null){
				pageSize = BeanUtils.stringToInt("pageSizeFlag", request.getParameter("pageSize"));
			}
			if(request.getParameter("startIndex")!=null){
				startIndex = BeanUtils.stringToInt("startIndexFlag", request.getParameter("startIndex"));
			}
			if(request.getParameter("process_code")!=null){ //取得动作流 流程英文名称，后台查询数据关联使用
				t_goods.setProcess_code(request.getParameter("process_code"));
			}

			if(request.getParameter("customer_id")!=null&&!"".equals(request.getParameter("customer_id"))){
				t_goods.setCustomer_id(request.getParameter("customer_id"));
			}
			if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
				t_goods.setStatus(request.getParameter("status"));
			}
			if(request.getParameter("goods_id")!=null&&!"".equals(request.getParameter("goods_id"))){
				t_goods.setGoods_id(new Integer(request.getParameter("goods_id")));
			}
			if(request.getParameter("product_id")!=null&&!"".equals(request.getParameter("product_id"))){
				t_goods.setProduct_id(new Integer(request.getParameter("product_id")));
			}
			if(request.getParameter("startdate")!=null&&!"".equals(request.getParameter("startdate"))){
				t_goods.setStartdate(request.getParameter("startdate"));
			}
			if(request.getParameter("enddate")!=null&&!"".equals(request.getParameter("enddate"))){
				t_goods.setEnddate(request.getParameter("enddate"));
			}
			if(request.getParameter("product_name1")!=null&&!"".equals(request.getParameter("product_name1"))){
				t_goods.setProduct_name1("&nbsp;&nbsp;"+request.getParameter("product_name1")+">>");
			}
			if(request.getParameter("product_name2")!=null&&!"".equals(request.getParameter("product_name2"))){
				//t_goods.setProduct_name2("&nbsp;&nbsp;"+ java.net.URLDecoder.decode(request.getParameter("product_name2"),"UTF-8")+">>");
				t_goods.setProduct_name2("&nbsp;&nbsp;"+ request.getParameter("product_name2")+">>");
			}
			if(request.getParameter("product_name3")!=null&&!"".equals(request.getParameter("product_name3"))){
				t_goods.setProduct_name3("&nbsp;&nbsp;"+request.getParameter("product_name3")+">>");
			}
			t_goods.setStartNo( startIndex );
			t_goods.setPageSize( pageSize );
			t_goods.setEndNo( pageSize );
			List<T_goods> findAll = t_goodsService.findAllT_goodsProduct(t_goods);
			int totalCount = t_goodsService.findCountAll(t_goods);
			pg = new Pg(findAll, totalCount, pageSize, startIndex);
			request.setAttribute("t_goodsList", findAll);
			request.setAttribute("pg", pg);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("------query t_goodsList error:"+e);
		}

		return pg;
	}


	/**
	 * 1、3获取 T_goods信息列表，并且在列表页面展示
	 * 此方法只用作搜索商品，并且不能搜出当前登录人所属公司的； 后天通过  customer_id != ## 判断；
	 * @param request
	 * @return Pg，json格式
	 */
	@RequestMapping("/getAllT_goodsBySearch")
	@ResponseBody
	public Pg getAllT_goodsBySearch(HttpServletRequest request){
		int pageSize = 10;
		int startIndex = 0;
		T_goods t_goods = new T_goods();
		try{
			if(request.getParameter("pageSize")!=null){
				pageSize = BeanUtils.stringToInt("pageSizeFlag", request.getParameter("pageSize"));
			}
			if(request.getParameter("startIndex")!=null){
				startIndex = BeanUtils.stringToInt("startIndexFlag", request.getParameter("startIndex"));
			}
			if(request.getParameter("process_code")!=null){ //取得动作流 流程英文名称，后台查询数据关联使用
				t_goods.setProcess_code(request.getParameter("process_code"));
			}
			if(request.getParameter("goods_name")!=null&&!"".equals(request.getParameter("goods_name"))){
				//t_goods.setGoods_name( java.net.URLDecoder.decode(request.getParameter("goods_name"),"UTF-8"));
				t_goods.setGoods_name( request.getParameter("goods_name"));
				if(t_goods.getGoods_name()!=null&&t_goods.getGoods_name()!=""){
					//1、首先去除左边、右边空格；
					String gname1 = t_goods.getGoods_name().trim();
					log.error("------去除左边、右边空格后，搜索的名称值为="+gname1);
					//2、切分：以空格切分；切分结果为数组；
					String[] gnArray = gname1.split(" ");
					log.error("------去除左边、右边空格后，搜索的名称split后值为="+gnArray);
					//3、把切分结果赋值给对应的属性，最多支持6个属性；
					for(int i=0;i<gnArray.length;i++){
						if(i==0){
							t_goods.setGoods_name0(gnArray[0]);							
						}
						else if(i==1){
							t_goods.setGoods_name1(gnArray[1]);							
						}
						else if(i==2){
							t_goods.setGoods_name2(gnArray[2]);							
						}
						else if(i==3){
							t_goods.setGoods_name3(gnArray[3]);							
						}
						else if(i==4){
							t_goods.setGoods_name4(gnArray[4]);							
						}
						else if(i==5){
							t_goods.setGoods_name5(gnArray[5]);							
						}
						else if(i==6){
							t_goods.setGoods_name6(gnArray[6]);							
						}
						else if(i==7){
							t_goods.setGoods_name6(gnArray[7]);							
						}
						else if(i==8){
							t_goods.setGoods_name6(gnArray[8]);							
						}
						log.error("------循环"+i+"="+i+";"+gnArray[i]);
					}
				}
			}
			if(request.getParameter("goods_info")!=null&&!"".equals(request.getParameter("goods_info"))){
				//t_goods.setGoods_info( java.net.URLDecoder.decode(request.getParameter("goods_info"),"UTF-8"));
				t_goods.setGoods_info( request.getParameter("goods_info"));
			}
			if(request.getParameter("goods_memo")!=null&&!"".equals(request.getParameter("goods_memo"))){
				//t_goods.setGoods_memo( java.net.URLDecoder.decode(request.getParameter("goods_memo"),"UTF-8"));
				t_goods.setGoods_memo( request.getParameter("goods_memo") );
			}
			if(request.getParameter("img_path")!=null&&!"".equals(request.getParameter("img_path"))){
				t_goods.setImg_path(request.getParameter("img_path"));
			}
			if(request.getParameter("isnew")!=null&&!"".equals(request.getParameter("isnew"))){
				t_goods.setIsnew(request.getParameter("isnew"));
			}
			if(request.getParameter("ishot")!=null&&!"".equals(request.getParameter("ishot"))){
				t_goods.setIshot(request.getParameter("ishot"));
			}
			if(request.getParameter("ext1")!=null&&!"".equals(request.getParameter("ext1"))){
				t_goods.setExt1(request.getParameter("ext1"));
			}
			if(request.getParameter("ext2")!=null&&!"".equals(request.getParameter("ext2"))){
				t_goods.setExt2(request.getParameter("ext2"));
			}
			if(request.getParameter("ext3")!=null&&!"".equals(request.getParameter("ext3"))){
				t_goods.setExt3(request.getParameter("ext3"));
			}
			if(request.getParameter("customer_id")!=null&&!"".equals(request.getParameter("customer_id"))){
				t_goods.setCustomer_id(request.getParameter("customer_id"));
			}
			if(request.getParameter("customer_name")!=null&&!"".equals(request.getParameter("customer_name"))){
				t_goods.setCustomer_name(request.getParameter("customer_name"));
			}
			if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
				t_goods.setStatus(request.getParameter("status"));
			}
			if(request.getParameter("goods_id")!=null&&!"".equals(request.getParameter("goods_id"))){
				t_goods.setGoods_id(new Integer(request.getParameter("goods_id")));
			}
			if(request.getParameter("product_id")!=null&&!"".equals(request.getParameter("product_id"))){
				t_goods.setProduct_id(new Integer(request.getParameter("product_id")));
			}
			if(request.getParameter("startdate")!=null&&!"".equals(request.getParameter("startdate"))){
				t_goods.setStartdate(request.getParameter("startdate"));
			}
			if(request.getParameter("enddate")!=null&&!"".equals(request.getParameter("enddate"))){
				t_goods.setEnddate(request.getParameter("enddate"));
			}
			if(request.getParameter("product_name1")!=null&&!"".equals(request.getParameter("product_name1"))){
				t_goods.setProduct_name1("&nbsp;&nbsp;"+request.getParameter("product_name1")+">>");
			}
			if(request.getParameter("product_name2")!=null&&!"".equals(request.getParameter("product_name2"))){
				//t_goods.setProduct_name2("&nbsp;&nbsp;"+ java.net.URLDecoder.decode(request.getParameter("product_name2"),"UTF-8")+">>");
				t_goods.setProduct_name2("&nbsp;&nbsp;"+ request.getParameter("product_name2")+">>");
			}
			if(request.getParameter("product_name3")!=null&&!"".equals(request.getParameter("product_name3"))){
				t_goods.setProduct_name3("&nbsp;&nbsp;"+request.getParameter("product_name3")+">>");
			}

			if(request.getParameter("orderByClause")!=null&&!"".equals(request.getParameter("orderByClause"))){
				t_goods.setOrderByClause(request.getParameter("orderByClause"));
			}

			t_goods.setStartNo( startIndex );
			t_goods.setPageSize( pageSize );
			t_goods.setEndNo( pageSize );
			List<T_goods> findAll = t_goodsService.findAllBySearch(t_goods);
			int totalCount = t_goodsService.findCountAllBySearch(t_goods);
			pg = new Pg(findAll, totalCount, pageSize, startIndex);
			request.setAttribute("t_goodsList", findAll);
			request.setAttribute("pg", pg);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("------query t_goodsList error:"+e);
		}

		return pg;
	}

	/**
	 * 1、4获取 T_goods信息列表，并且在列表页面展示
	 * @param request
	 * @return Pg，json格式
	 */
	@RequestMapping("/findAllT_goodsProductBySearch")
	@ResponseBody
	public Pg findAllT_goodsProductBySearch(HttpServletRequest request){
		int pageSize = 1000;
		int startIndex = 0;
		T_goods t_goods = new T_goods();
		try{
			if(request.getParameter("pageSize")!=null){
				pageSize = BeanUtils.stringToInt("pageSizeFlag", request.getParameter("pageSize"));
			}
			if(request.getParameter("startIndex")!=null){
				startIndex = BeanUtils.stringToInt("startIndexFlag", request.getParameter("startIndex"));
			}
			if(request.getParameter("goods_name")!=null&&!"".equals(request.getParameter("goods_name"))){
				t_goods.setGoods_name( request.getParameter("goods_name"));
				if(t_goods.getGoods_name()!=null&&t_goods.getGoods_name()!=""){
					//1、首先去除左边、右边空格；
					String gname1 = t_goods.getGoods_name().trim();
					log.error("------去除左边、右边空格后，搜索的名称值为="+gname1);
					//2、切分：以空格切分；切分结果为数组；
					String[] gnArray = gname1.split(" ");
					log.error("------去除左边、右边空格后，搜索的名称split后值为="+gnArray);
					//3、把切分结果赋值给对应的属性，最多支持6个属性；
					for(int i=0;i<gnArray.length;i++){
						if(i==0){
							t_goods.setGoods_name0(gnArray[0]);							
						}
						else if(i==1){
							t_goods.setGoods_name1(gnArray[1]);							
						}
						else if(i==2){
							t_goods.setGoods_name2(gnArray[2]);							
						}
						else if(i==3){
							t_goods.setGoods_name3(gnArray[3]);							
						}
						else if(i==4){
							t_goods.setGoods_name4(gnArray[4]);							
						}
						else if(i==5){
							t_goods.setGoods_name5(gnArray[5]);							
						}
						else if(i==6){
							t_goods.setGoods_name6(gnArray[6]);							
						}
						else if(i==7){
							t_goods.setGoods_name6(gnArray[7]);							
						}
						else if(i==8){
							t_goods.setGoods_name6(gnArray[8]);							
						}
						log.error("------循环"+i+"="+i+";"+gnArray[i]);
					}
				}

			}
			if(request.getParameter("goods_info")!=null&&!"".equals(request.getParameter("goods_info"))){
				t_goods.setGoods_info( request.getParameter("goods_info"));
			}
			if(request.getParameter("goods_memo")!=null&&!"".equals(request.getParameter("goods_memo"))){
				t_goods.setGoods_memo( request.getParameter("goods_memo"));
			}
			if(request.getParameter("img_path")!=null&&!"".equals(request.getParameter("img_path"))){
				t_goods.setImg_path(request.getParameter("img_path"));
			}
			if(request.getParameter("isnew")!=null&&!"".equals(request.getParameter("isnew"))){
				t_goods.setIsnew(request.getParameter("isnew"));
			}
			if(request.getParameter("ishot")!=null&&!"".equals(request.getParameter("ishot"))){
				t_goods.setIshot(request.getParameter("ishot"));
			}
			if(request.getParameter("ext1")!=null&&!"".equals(request.getParameter("ext1"))){
				t_goods.setExt1(request.getParameter("ext1"));
			}
			if(request.getParameter("ext2")!=null&&!"".equals(request.getParameter("ext2"))){
				t_goods.setExt2(request.getParameter("ext2"));
			}
			if(request.getParameter("ext3")!=null&&!"".equals(request.getParameter("ext3"))){
				t_goods.setExt3(request.getParameter("ext3"));
			}
			if(request.getParameter("customer_id")!=null&&!"".equals(request.getParameter("customer_id"))){
				t_goods.setCustomer_id(request.getParameter("customer_id"));
			}
			if(request.getParameter("customer_name")!=null&&!"".equals(request.getParameter("customer_name"))){
				t_goods.setCustomer_name(request.getParameter("customer_name"));
			}
			if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
				t_goods.setStatus(request.getParameter("status"));
			}
			if(request.getParameter("goods_id")!=null&&!"".equals(request.getParameter("goods_id"))){
				t_goods.setGoods_id(new Integer(request.getParameter("goods_id")));
			}
			if(request.getParameter("product_id")!=null&&!"".equals(request.getParameter("product_id"))){
				t_goods.setProduct_id(new Integer(request.getParameter("product_id")));
			}
			if(request.getParameter("startdate")!=null&&!"".equals(request.getParameter("startdate"))){
				t_goods.setStartdate(request.getParameter("startdate"));
			}
			if(request.getParameter("enddate")!=null&&!"".equals(request.getParameter("enddate"))){
				t_goods.setEnddate(request.getParameter("enddate"));
			}
			if(request.getParameter("product_name1")!=null&&!"".equals(request.getParameter("product_name1"))){
				t_goods.setProduct_name1("&nbsp;&nbsp;"+request.getParameter("product_name1")+">>");
			}
			if(request.getParameter("product_name2")!=null&&!"".equals(request.getParameter("product_name2"))){
				t_goods.setProduct_name2("&nbsp;&nbsp;"+request.getParameter("product_name2")+">>");
			}
			if(request.getParameter("product_name3")!=null&&!"".equals(request.getParameter("product_name3"))){
				t_goods.setProduct_name3("&nbsp;&nbsp;"+request.getParameter("product_name3")+">>");
			}

			t_goods.setStartNo( startIndex );
			t_goods.setPageSize( pageSize );
			t_goods.setEndNo( pageSize );
			List<T_goods> findAll = t_goodsService.findAllT_goodsProductBySearch(t_goods);
			int totalCount =100000; //t_goodsService.findCountAll(t_goods);
			pg = new Pg(findAll, totalCount, pageSize, startIndex);
			request.setAttribute("t_goodsList", findAll);
			request.setAttribute("pg", pg);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("------query t_goodsList error:"+e);
		}

		return pg;
	}

	/**
	 * 2、新增保存  T_goods信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_goods
	 * @param request
	 * @return
	 */
	@RequestMapping("/saveT_goods")
	//@ResponseBody
	public void saveT_goods(T_goods t_goods, HttpServletRequest request, HttpServletResponse response, @RequestParam("filesZtp") MultipartFile[] files,  @RequestParam("filesXqtp") MultipartFile[] filesXqtp){
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+ request.getContextPath()+"/";
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);

		//判断是否登录，如果session无效，则直接跳转到登录，不保存订单；
		if(request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID)==null||request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID)==""){
			log.error("------saveT_goods ERROR: session 为空，session="+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID));
			log.error("------saveT_goods ERROR: 保存商品失败！goods_name="+t_goods.getGoods_name());
			log.error("------saveT_goods ERROR: 保存商品失败！goods_num="+t_goods.getNum());
			log.error("------saveT_goods ERROR: 保存商品失败！buyer="+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID));
			vo.setInfo("saveT_goods失败，因为session信息不存在，请重新登录后再操作！");
			//return "redirect:"+tempBathPath;
			try {
				response.sendRedirect(basePath);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}else{

			String img_path = "";
			t_goods.setCreater(""+request.getSession().getAttribute(LxConstans.SESSION_USER_CUSTOMER_ID));
			t_goods.setCreattime(com.common.utils.DateUtil.getCurrDateTime());
			t_goods.setCompany_name(""+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_TEL));//电话信息

			t_goods.setCustomer_id(""+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID)); //存储企业数字主键，以便一个企业多个操作员新增时，看到的customer_id是相同的
			//t_goods.setCustomer_address(""+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ADDRESS));
			//t_goods.setCustomer_name(""+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_NAME));  //企业名称
			t_goods.setSalenum(0);
			t_goods.setPrice5(new Double(100) );

			//如果有特殊需求，需要将json对象值转成java实体对象属性值
			int goods_id = t_goodsService.save(t_goods);
			if(goods_id>0){
				vo.setResult("success");
				vo.setJieguo(true);
				vo.setInfo("保存商品信息成功，即将处理上传图片！");
			}

			log.debug("------上传商品图片文件开始！------");
			//主图片----判断file数组不能为空并且长度大于0
			if(files!=null&&files.length>0){
				log.debug("------本次上传文件个数="+files.length);
				//循环获取file数组中得文件
				for(int i = 0;i<files.length;i++){
					MultipartFile file = files[i];
					//保存文件
					String tempName = saveFile(request, file, t_goods,i,"z");
					if(!"".equals(tempName)&&null!=tempName){
						img_path += tempName+";"; //把多个文件以“；”链接起来；
					}
				}
			}

			//详情图片----判断file数组不能为空并且长度大于0
			if(filesXqtp!=null&&filesXqtp.length>0){
				log.debug("------本次上传文件个数="+filesXqtp.length);
				//循环获取file数组中得文件
				for(int i = 0;i<filesXqtp.length;i++){
					MultipartFile fileXqtp = filesXqtp[i];
					//保存文件
					String tempName = saveFile(request, fileXqtp, t_goods,i,"x");
					//				if(!"".equals(tempName)&&null!=tempName){
					//					img_path += tempName+";"; //把多个文件以“；”链接起来；
					//				}
				}
			}

			// 更新img_path；
			T_goods ugoods = new T_goods();
			ugoods = t_goodsService.findById(t_goods);
			ugoods.setImg_path(img_path);
			t_goodsService.update(ugoods);

			log.debug("------商品添加完毕！------");
			//这里window.parent.uploadSuccess()是我在前端页面中写好的javascript function,此方法主要用于输出异常和上传成功后的图片地址
            //如果成功返回的数据是需要返回两个字符串，我在这里使用了|分隔  例： 成功信息|/Test/hello.jpg
			response.setContentType("text/html;charset=UTF-8");
			try {
				if(vo.getResult().equals("success")){
					//response.sendRedirect(basePath+"publish_add_success");
					response.getWriter().print("<script>window.parent.uploadSuccess('success!|恭喜你，新增商品成功！')</script>");
					//return "<script langeuage=javascript>alert('新增商品成功！')</script>";
				}else{
					//response.sendRedirect(basePath+"publish_add_failed");
					response.getWriter().print("<script>window.parent.uploadSuccess('对不起，新增商品失败！');</script>");
					//<script langeuage=javascript>alert('新增商品失败！')</script>";
				}

			} catch (Exception e) {
				e.printStackTrace();
				log.error("------新增商品遇到错误："+e);
				try {

					response.getWriter().print("<script>window.parent.uploadSuccess('对不起，新增商品失败！失败原因："+e+"')</script>");
				} catch (IOException e1) {
					e1.printStackTrace();
				}
			}
		}

		//return vo;
	}

	/***
	 * 保存文件
	 *  String getContentType()//获取文件MIME类型
		InputStream getInputStream()//后去文件流
		String getName() //获取表单中文件组件的名字
		String getOriginalFilename() //获取上传文件的原名
		long getSize() //获取文件的字节大小，单位byte
		boolean isEmpty() //是否为空
		void transferTo(File dest) //保存到一个目标文件中。
	 * @param file
	 * @type z:主图图片， x:详情图片；
	 * @return
	 */
	private String saveFile(HttpServletRequest request, MultipartFile file, T_goods goods, int i, String type) {
		// 判断文件是否为空
		if (!file.isEmpty()) {
			try {
				String oldFileName = file.getOriginalFilename();
				log.debug("------fileName="+file.getName());

				String newFileNameSuf = oldFileName.substring(oldFileName.lastIndexOf(".")).toLowerCase();
				//新的文件名：customer_id_yyyyMMddHHmmss 格式；,把循环位置加上，防止程序执行过快，出现同名的文件名。
				String newFileName = goods.getCustomer_id()+"_"+com.common.utils.DateUtil.getCurrDateTime()+"_"+type+i+"_" + newFileNameSuf;
				// 文件保存路径
				String filePath = request.getSession().getServletContext().getRealPath("/") + "upload/goods/"+ newFileName;
				log.debug("------file="+filePath+";oldFileName="+oldFileName+";newFileName="+newFileName);
				//如果文件名称中涵：.exe;.bat等可执行文件，提示失败；
				if(true){

				}
				//如果文件大于5M,不保存该文件
				if(file.getSize()<1024*1024*5){
					// 转存文件
					file.transferTo(new File(filePath));
					//保存商品图片信息到t_img表；
					T_img obj = new T_img();
					obj.setGoods_id(goods.getGoods_id());
					obj.setImg_path(newFileName);
					obj.setCustomer_id(goods.getCustomer_id());
					obj.setCreater(goods.getCreater());
					obj.setCreattime(goods.getCreattime());
					obj.setUpdater(goods.getUpdater());
					obj.setUpdatetime(goods.getUpdatetime());
					obj.setCompany_name(goods.getCompany_name());
					obj.setStatus(type);

					t_imgService.save(obj);

					return newFileName;
				}
				log.debug("------文件："+filePath+" 大于5M,不保存，请上传小于5M的图片文件！");

				return "";
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return "";
	}

	/**
	 * 3、修改T_goods信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_goods
	 * @param request
	 * @return JsonVO
	 * @throws Exception
	 */
	@RequestMapping("/updateT_goods")
	@ResponseBody
	public void updateT_goods(T_goods t_goods, HttpServletRequest request, HttpServletResponse response, @RequestParam("filesZtp") MultipartFile[] files,  @RequestParam("filesXqtp") MultipartFile[] filesXqtp) throws Exception{
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+ request.getContextPath()+"/";
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);

		//判断是否登录，如果session无效，则直接跳转到登录，不保存订单；
		if(request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID)==null||request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID)==""){
			log.error("------updateT_goods ERROR: session 为空，session="+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID));
			log.error("------updateT_goods ERROR: 更新商品失败！goods_name="+t_goods.getGoods_name());
			log.error("------updateT_goods ERROR: 更新商品失败！goods_num="+t_goods.getNum());
			log.error("------updateT_goods ERROR: 更新商品失败！buyer="+request.getSession().getAttribute(LxConstans.SESSION_USER_COMPANY_ID));
			vo.setInfo("updateT_goods失败，因为session信息不存在，请重新登录后再操作！");
			//return "redirect:"+tempBathPath;
			try {
				response.sendRedirect(basePath);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}else{
			//首先根据id从后天取出对象，然后对该对象重新赋值；
			T_goods ugoods = new T_goods();
			ugoods = t_goodsService.findById(t_goods);

			//前台更新商品信息；
			ugoods.setUpdater(""+request.getSession().getAttribute(LxConstans.SESSION_USER_CUSTOMER_ID));
			ugoods.setUpdatetime(com.common.utils.DateUtil.getCurrDateTime());
			//设置前台页面上修改的属性值；
			if(t_goods.getProduct_id()==null||"".equals( t_goods.getProduct_id()) ){
				log.error("------updateT_goods ERROR: t_goods.getProduct_id() is null or 空！ updater CUSTOMERID="+request.getSession().getAttribute("CUSTOMERID"));
				log.error("------updateT_goods ERROR: t_goods.getProduct_id() is null or 空！updater time="+ugoods.getUpdatetime());
				log.error("------updateT_goods ERROR: t_goods.getProduct_id() is null or 空！goods_id="+t_goods.getGoods_id()+";goods_name="+t_goods.getGoods_name());
				log.error("------updateT_goods ERROR: t_goods.getProduct_id() is null or 空！getProduct_id="+t_goods.getProduct_id());
				response.sendRedirect(basePath+"publish_edit_failed");
			}
			ugoods.setProduct_id(t_goods.getProduct_id());
			ugoods.setProduct_name1(t_goods.getProduct_name1());
			ugoods.setProduct_name2(t_goods.getProduct_name2());
			ugoods.setProduct_name3(t_goods.getProduct_name3());
			ugoods.setGoods_name(t_goods.getGoods_name());
			ugoods.setGoods_info(t_goods.getGoods_info());
			ugoods.setGoods_memo(t_goods.getGoods_memo());
			ugoods.setOld_price(t_goods.getOld_price());
			ugoods.setPrice(t_goods.getPrice());
			ugoods.setNum(t_goods.getNum());
			log.error("------旧的  updateT_goods ugoods.getIshot ="+ugoods.getIshot());
			log.error("------新的  updateT_goods t_goods.getIshot ="+t_goods.getIshot());
			ugoods.setIshot(t_goods.getIshot());
			ugoods.setCustomer_address(t_goods.getCustomer_address());
			ugoods.setCustomer_name(t_goods.getCustomer_name());
			ugoods.setExt3(t_goods.getExt3());

			//如果有特殊需求，需要将json对象值转成java实体对象属性值
			int ret = t_goodsService.update(ugoods);
			if(ret>0){
				vo.setResult("success");
				vo.setJieguo(true);
			}

			log.debug("------上传商品图片文件开始！------");
			//判断file数组不能为空并且长度大于0
			if(files!=null&&files.length>0){
				log.debug("------本次上传文件个数="+files.length);
				//循环获取file数组中得文件
				for(int i = 0;i<files.length;i++){
					MultipartFile file = files[i];
					//保存文件
					String tempName = saveFile(request, file, t_goods, i, "z");
					//				if(!"".equals(tempName)&&null!=tempName){
					//					img_path += tempName+";"; //把多个文件以“；”链接起来；
					//				}
				}
			}

			//详情图片----判断file数组不能为空并且长度大于0
			if(filesXqtp!=null&&filesXqtp.length>0){
				log.debug("------本次上传文件个数="+filesXqtp.length);
				//循环获取file数组中得文件
				for(int i = 0;i<filesXqtp.length;i++){
					MultipartFile fileXqtp = filesXqtp[i];
					//保存文件
					String tempName = saveFile(request, fileXqtp, t_goods,i,"x");
					//				if(!"".equals(tempName)&&null!=tempName){
					//					img_path += tempName+";"; //把多个文件以“；”链接起来；
					//				}
				}
			}

			// 更新img_path；需要从数据库中把该商品对应的图片全部查询出来，加工成需要值；然后再更新该商品的图片属性值；
			//现改为把old主图片路径，加上新的主图片路径
			String img_path = "";
			T_img obj_img = new T_img();
			obj_img.setGoods_id(t_goods.getGoods_id());
			obj_img.setStartNo(0);
			obj_img.setEndNo(1000);
			List imgList = t_imgService.findAll(obj_img);
			if(imgList!=null&&imgList.size()!=0){
				Iterator it = imgList.iterator();
				while(it.hasNext()){
					T_img tempImg = (T_img)it.next();
					//如果tempImg中的status是主图类型：z;则加入到主图路径中；
					if(tempImg.getImg_path()!=null&&tempImg.getImg_path()!=""){
						if(tempImg.getStatus()!=null&&tempImg.getStatus().equals("z")){  //z:主图类型
							img_path += tempImg.getImg_path()+";";
						}else{
							log.debug("------修改商品信息时，判断图片img_path是否包含在old主图片img_path中：是！"+tempImg.getImg_path());
						}
					}
				}
			}

			ugoods.setImg_path(img_path);
			t_goodsService.update(ugoods);

			// 设置img_path
			//t_goods.setImg_path(img_path);
			//t_goodsService.update(t_goods);

			try {
				if(vo.getResult().equals("success")){
					response.sendRedirect(basePath+"publish_edit_success");
				}else{
					response.sendRedirect(basePath+"publish_edit_failed");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		//return vo;
	}

	/**
	 * 3、修改T_goods信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_goods
	 * @param request
	 * @return JsonVO
	 */
	@RequestMapping("/updateT_ads_goods")
	@ResponseBody
	public JsonVO updateT_ads_goods(T_goods t_goods, HttpServletRequest request, HttpServletResponse response){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		T_goods newgoods = t_goodsService.findById(t_goods);

		//后台操作人员的登录标示；SESSIONNAME = "FREE_CURRENT_USER"; //session用户标示；
		newgoods.setUpdater(""+request.getSession().getAttribute("FREE_CURRENT_USER"));
		newgoods.setUpdatetime(com.common.utils.DateUtil.getCurrDateTime());
		newgoods.setIsnew(t_goods.getIsnew());

		//如果有特殊需求，需要将json对象值转成java实体对象属性值
		int ret = t_goodsService.update(newgoods);
		if(ret>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}

		return vo;
	}

	/**
	 * 3、2修改T_goods信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_goods
	 * @param request
	 * @return JsonVO
	 */
	@RequestMapping("/updateT_goodsByNewNum")
	@ResponseBody
	public JsonVO updateT_goodsByNewNum( int goods_id, int newKcNum, int newPrice, int oldPrice,int xhNum, String newGoodName, HttpServletRequest request, HttpServletResponse response){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		T_goods t_goods = new T_goods();
		t_goods.setGoods_id(goods_id);
		T_goods newgoods = t_goodsService.findById(t_goods);

		newgoods.setNum(newKcNum);
		newgoods.setPrice( new Double(newPrice) );
		newgoods.setOld_price( new Double(oldPrice) );
		newgoods.setGoods_name( newGoodName );
		newgoods.setPrice5( new Double(xhNum) );
		//后台操作人员的登录标示；SESSIONNAME = "FREE_CURRENT_USER"; //session用户标示；
		newgoods.setUpdater(""+request.getSession().getAttribute(LxConstans.SESSION_USER_CUSTOMER_ID));
		newgoods.setUpdatetime(com.common.utils.DateUtil.getCurrDateTime());

		//如果有特殊需求，需要将json对象值转成java实体对象属性值
		int ret = t_goodsService.update(newgoods);
		if(ret>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}

		return vo;
	}

	/**
	 * 3、3修改T_goods信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * 后台工作人员修改；
	 * @param t_goods
	 * @param request
	 * @return JsonVO
	 * 	var url = "<%=basePath%>t_goods/updateT_goodsByHT?goods_id="+goodsid+"&newGoodName="+newGoodName+"&oldPrice="+oldPrice+"&salenumNum="+salenumNum+"&time="+Math.random();
	 */
	@RequestMapping("/updateT_goodsByHT")
	@ResponseBody
	public JsonVO updateT_goodsByHT( int goods_id, String newGoodName, int oldPrice, int salenumNum, HttpServletRequest request, HttpServletResponse response){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		T_goods t_goods = new T_goods();
		t_goods.setGoods_id(goods_id);
		T_goods newgoods = t_goodsService.findById(t_goods);

		newgoods.setGoods_name( newGoodName );
		newgoods.setOld_price( new Double(oldPrice) );
		newgoods.setSalenum(salenumNum);
		
		//后台操作人员的登录标示；SESSIONNAME = "FREE_CURRENT_USER"; //session用户标示；
		newgoods.setUpdater(""+request.getSession().getAttribute("FREE_CURRENT_USER"));
		newgoods.setUpdatetime(com.common.utils.DateUtil.getCurrDateTime());

		//如果有特殊需求，需要将json对象值转成java实体对象属性值
		int ret = t_goodsService.update(newgoods);
		if(ret>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}

		return vo;
	}
	
	/**
	 * 4、根据id查询T_goods单个信息并显示在修改页面
	 * @param id
	 * @param request
	 * @return T_goods json格式字符串
	 */
	@RequestMapping("/getT_goods")
	@ResponseBody
	public T_goods getT_goods(Integer id,HttpServletRequest request){
		T_goods t_goods = new T_goods();
		t_goods.setGoods_id(id);
		return t_goodsService.findById(t_goods);
	}

	/**
	 * 5、删除T_goods根据id
	 * @param id
	 * @param request
	 * @param response
	 * return JsonVO ：json格式字符串
	 */
	@RequestMapping("/delT_goods")
	@ResponseBody
	public JsonVO delT_goods(Integer id,HttpServletRequest request,HttpServletResponse response){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);

		T_goods t_goods = new T_goods();
		t_goods.setGoods_id(id);

		if(t_goodsService.delete(t_goods)>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}
		return vo;
	}

	/**
	 * 6、跳转到t_goods/toT_goodsList查询所有数据页面
	 *  return /WEB-INF/views/business/t_goods/t_goodsList.jsp
	 */
	@RequestMapping(value = "/toT_goodsList")
	public String toT_goodsList() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/t_goodsList.jsp------");
		return "business/t_goods/t_goodsList";
	}

	/**
	 * 7、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_goodsCurd")
	public String toT_goodsCurd() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/t_goodsCurd.jsp------");
		return "business/t_goods/t_goodsCurd";
	}

	/**
	 * 7\2、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_ads_goodsList")
	public String toT_ads_goodsList() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/t_ads_goodsList.jsp------");
		return "business/t_goods/t_ads_goodsList";
	}
	/**
	 * 7\3、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_ads_goodsCurd")
	public String toT_ads_goodsCurd() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/toT_ads_goodsCurd.jsp------");
		return "business/t_goods/t_ads_goodsCurd";
	}
	/**
	 * 7\4、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_jf_goodsList")
	public String toT_jf_goodsList() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/t_jf_goodsList.jsp------");
		return "business/t_goods/t_jf_goodsList";
	}

	/**
	 * 7\5、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_jf_goodsCurd")
	public String toT_jf_goodsCurd() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/toT_jf_goodsCurd.jsp------");
		return "business/t_goods/t_jf_goodsCurd";
	}

	/**
	 * 7\6、新增、修改、详情页面t_goods/toT_goodsCurd跳转
	 * business/t_goods/T_goodsCurd.jsp
	 */
	@RequestMapping(value = "/toT_pfs_goodsList")
	public String toT_pfs_goodsList() {
		log.debug("------跳转到/WEB-INF/views/business/t_goods/toT_pfs_goodsList.jsp------");
		return "business/t_goods/t_pfs_goodsList";
	}


	/**
	 * 9、批量保存T_goods根据主键id
	 * @param id
	 * @param request
	 * @param response

	@RequestMapping("/pfsT_goodsBatchSave")
	public String pfsT_goodsBatchSave( HttpServletRequest request,HttpServletResponse response){
		String[] ids = request.getParameterValues("batchSelected");
		System.out.println("------ids="+ids.toString());
		//查询目标company的相关信息；
		T_company company = new T_company();
		String to_customer =request.getParameter("to_customer_id");
		company.setCompany_id(new Integer( to_customer ));
		company = t_companyService.findById(company);

		//循环保存目标批发商商品
		T_goods t_goods = new T_goods();
		int j=0;
		for(int i =0;i< ids.length;i++){
			j++;
			//log.error("------ids[i]="+ids[i]);
			//查询老商品信息；
			Integer old_goods_id = new Integer(ids[i]).intValue();
			t_goods.setGoods_id(old_goods_id);
			log.error("------ids["+i+"]="+ids[i]);
			T_goods goodsTemp = t_goodsService.findById(t_goods);
			//加工新商品信息；
			goodsTemp.setGoods_id(null);
			goodsTemp.setCustomer_id(to_customer);
			goodsTemp.setCustomer_address(company.getCompany_addres());
			goodsTemp.setCustomer_name(company.getCompany_name());
			goodsTemp.setCompany_name(company.getCompany_tel()); //电话；

			goodsTemp.setCreater(""+request.getSession().getAttribute("FREE_CURRENT_USER") ); //后天操作员id，不是前台的；
			goodsTemp.setCreattime(com.common.utils.DateUtil.getCurrDateTime());
			goodsTemp.setUpdater("");
			goodsTemp.setUpdatetime("");
			goodsTemp.setPrice5( new Double(100) );

			//保存新商品
			int retvalue = t_goodsService.save(goodsTemp); //retvalue是返回的goods_id;

			//循环插入图片；
			//查询出该商品原来对应的图片，按照新商品图片插入到图片表；
			T_img oldimg = new T_img();
			oldimg.setGoods_id(old_goods_id);
			oldimg.setStartNo(0);
			oldimg.setEndNo(1000);
			List  oldimgList = t_imgService.findAll(oldimg);
			if(oldimgList!=null&&oldimgList.size()!=0){
				Iterator oldimgit = oldimgList.iterator();
				while(oldimgit.hasNext()){
					 oldimg = (T_img) oldimgit.next();
					 //设置新商品img属性值；
					 oldimg.setImg_id(null);
					 oldimg.setGoods_id(goodsTemp.getGoods_id()); //设置对应的新的商品id
					 oldimg.setCustomer_id(to_customer);
					 oldimg.setCreater(""+request.getSession().getAttribute("FREE_CURRENT_USER"));
					 oldimg.setCreattime(com.common.utils.DateUtil.getCurrDateTime());
					 oldimg.setCompany_name(company.getCompany_name());
					 //保存新商品对应图片信息；
					 int retimgvalue = t_imgService.save(oldimg);
					 log.error("------循环保存批发商"+to_customer+"商品图片,商品名称："+goodsTemp.getGoods_name()+"；图片名称："+oldimg.getImg_path()+";结果："+retimgvalue);
				}

			}

			log.error("------循环保存批发商"+to_customer+"商品,商品名称："+goodsTemp.getGoods_name()+"；结果："+retvalue);
		}
		if(j==ids.length){
			log.debug("------批发商商品 t_goods批量保存成功！------");
		}else{
			log.error("------批发商商品 t_goods批量保存部分成功！部分失败！------");
		}

		return "redirect:/t_goods/toT_pfs_goodsList";
	}
	 */

	/**
	 * 8、批量删除T_goods根据主键id
	 * 是否要实现批量删除，待考虑，基本上用途不大
	 * @param id
	 * @param request
	 * @param response
	@RequestMapping("/delT_goodsBatch")
	public String delT_goodsBatch(HttpServletRequest request,HttpServletResponse response){
		String[] ids = request.getParameterValues("ids");
		System.out.println("------ids="+ids);
		T_goods t_goods = new T_goods();
		int j=0;
		for(int i =0;i< ids.length;i++){
			j++;
			log.error("------ids[i]="+ids[i]);
			t_goods.setGoods_id(new Integer(ids[i]).intValue());
			t_goodsService.delete(t_goods);
		}
		if(j==ids.length){
			log.debug("------t_goods批量删除成功！------");
		}else{
			log.error("------t_goods批量删除部分成功！部分失败！------");
		}

		return "redirect:/t_goods/getAllT_goods";
	}
	 */



}









